﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Data;
using IUI;

namespace BL
{
    public class LoginController : BaseController<ILogin>
    {
      public LoginController(ILogin page) : base(page) 
      {
      }
              
      public override void InitPageEvents()
      {
         _page.Click_LoginButton += ButtonClick;
      }

      private void ButtonClick(object sender, EventArgs e)
      {
          if (_page.strLogin == "" || _page.strPasswd == "")
          {
              //_page.ShowError(true);
              return;
          }
          else{ 
              User tmp = WCF_Client.Instance.CreateUser(_page.strLogin, _page.strPasswd);
              if (null != tmp)
              {
                  _page.Success(tmp);
              }
              else
              {
                  _page.ShowError();
              }
          }
      }
    }
}
